<link rel="stylesheet" type="text/css" href="assets/bootstrap-datepicker/css/datepicker.css" />
<section id="main-content">
  <section class="wrapper">
    <!--state overview end-->
    <div class="row">
      <div class="col-lg-12">
        <section class="panel">
          <header class="panel-heading">
            验收报告信息
          </header>
          <form>
            <div class="panel-body">
              <div class="form-group customerForm">
                <label class="col-sm-2 control-label">归属项目</label>
                <div class="col-sm-10">
                  <input type="text" id="proName" name="proName" class="form-control">
                  <input type="hidden" value="" name="proId" certus-required id="proId" />
                </div>
              </div>
              <div class="form-group customerForm">
                <label class="col-sm-2 control-label">合同编号</label>
                <div class="col-sm-10">
                  <select class="form-control" certus-required name="contractId" id="contractId">
                    <option value="" selected>请选择</option>
                    <option ng-repeat="d in data" value="{{d.code}}">{{d.code}}</option>
                  </select>
                </div>
              </div>
              <div class="form-group customerForm">
                <label class="col-sm-2 control-label">类型</label>
                <div class="col-sm-10">
                  <select class="form-control" name="acceptanceType" certus-required>
                    <option value="">请选择</option>
                    <option value="初验">初验</option>
                    <option value="验收">验收</option>
                    <option value="终验">终验</option>
                  </select>
                </div>
              </div>
              <div class="form-group customerForm">
                <label class="col-sm-2 control-label">验收签字人</label>
                <div class="col-sm-10">
                  <input type="text" class="form-control" name="customerName" certus-required>
                </div>
              </div>
              <div class="form-group customerForm">
                <label class="col-sm-2 control-label">验收日期</label>
                <div class="col-sm-10">
                  <input id="acceptanceTime" name="acceptanceTime" type="text" value="" class="form-control"
                    certus-required>
                </div>
              </div>
              <div class="form-group customerForm">
                <label class="col-sm-2 control-label">验收结果</label>
                <div class="col-sm-10">
                  <select class="form-control" name="acceptanceResult" certus-required>
                    <option value="通过">通过</option>
                    <option value="不通过">不通过</option>‘
                    <option value="部分通过">部分通过</option>
                  </select>
                </div>
              </div>
              <div class="form-group customerForm">
                <label class="col-sm-2 control-label">验收结果信息说明</label>
                <div class="col-sm-10">
                  <textarea class="form-control" maxlength="120" name="acceptanceComments" certus-required></textarea>
                </div>
              </div>
             
            </div>
          </form>
        </section>
        <section class="panel">
          <div class="panel-body">
              <p class="default-buttons">
                  <a href="javascript:void(0);" class="button-back btn btn-info" onclick="window.history.back()">返回</a>
                  <a href="javascript:void(0);" class="button-next  btn btn-success toRegu">确认提交</a>
                </p>
          </div>
        </section>
      </div>
    </div>
  </section>
</section>
<script type="text/javascript" src="js/autocomplete/jquery.autocomplete.js"></script>
<script type="text/javascript" src="assets/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
<script>
  $('#acceptanceTime').datepicker({
    format: 'yyyy-mm-dd'
  });

  var $CertusFormAjax="";
  var $$scope = "";
  function addAccept($scope, CertusFormAjax) {
      $CertusFormAjax = CertusFormAjax;
      $$scope = $scope;
    CertusFormAjax.ajax("findSeProList", {}, function (response) {
      var nhlTeams = [];
      var data = response.data;
      for (var i = 0; i < data.length; i++) {
        var arr = {};
        arr.name = data[i].proName;
        arr.id = data[i].id;
        nhlTeams.push(arr);
      }
      //自动补全
      var nhl = $.map(nhlTeams, function (obj) {
        return {
          value: obj.name,
          data: {
            category: obj.id
          }
        };
      });
      // Initialize autocomplete with local lookup:
      $('#proName').devbridgeAutocomplete({
        lookup: nhl,
        minChars: 1,
        onSelect: function (suggestion) {
          $("#proId").val(suggestion.data.category);
        },
        showNoSuggestionNotice: true,
        noSuggestionNotice: 'Sorry, no matching results'
      });
    });

    // this.getContract  = function () {
    //     var proId = getproId();
    //     console.log(proId);
    //     if (proId!=""){
    //         CertusFormAjax.ajax("contractProgresss",{"projId":proId},function (response) {
    //             var data = response.data;
    //             var codeList = [];
    //             for (var i=0;i<data.length;i++){
    //                 var ctinfo = data[i].contractInfo;
    //                 var arr ={};
    //                 arr.code = ctinfo.contractNo;
    //                 codeList.push(arr)
    //             }
    //             $scope.data = codeList;
    //         });
    //     }
    // };

    $(".toRegu").on('click', function () {
      if (!certusValidateNotnull()) {
        return;
      }
      // fileUpload($$scope,function (res){
      var arr = $("form").serializeArray();
      var data = {};
      for (var i = 0; i < arr.length; i++) {
        data[arr[i].name] = arr[i].value;
      };
      //上传附件
      CertusFormAjax.ajax("addAccetpances", {
        "projId": $("#proId").val(),
        "param": JSON.stringify(data)
      }, function () {
        layer.msg("添加成功", {
          "time": 1000
        });
        window.history.back();
      });
      // },null,$certusUtils);
    });
  }

  function getlist(proId) {
      // var proId = getproId();
      if (proId!=""){
          $CertusFormAjax.ajax("contractProgresss",{"projId":proId},function (response) {
              var data = response.data;
              var codeList = [];
              for (var i=0;i<data.length;i++){
                  var ctinfo = data[i].contractInfo;
                  var arr ={};
                  arr.code = ctinfo.contractNo;
                  codeList.push(arr)
              }
              $$scope.data = codeList;
          });
          // localStorage.clear();
      }
  };

  //
  // function getproId() {
  //   var proId = localStorage.getItem("sproId")
  //   return proId
  // }
</script>